package com.lihepeng.leecode.array2;

/**
 * 两数之和 二
 */
public class Solution167 {
    public int[] twoSum(int[] numbers, int target) {
        int [] result = new int[2];
        int left =0;
        int right = numbers.length-1;
        result[0] = -1;
        result[1] = -1;
        while (left<right) {
            int sum = numbers[left] + numbers[right];
            if (sum == target) {
                result[0] = left+1;
                result[1] = right+1;
                return result;
            }else if (sum < target) {
                left++;
            }else {
                right --;
            }
        }
        result[0] = -1;
        result[1] = -1;
        return result;

    }
}
